{extend name="public/world"}
{block name="style"}{/block}
{block name="container"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-form" lay-filter="formSearch">
                <div class="layui-field-box" style="padding:0;">
                    <div class="layui-form-item" style="margin-bottom:0">
                        <div class="layui-inline my-search">
                            <div class="layui-input-inline">
                                <select name="roleid" lay-filter="roleid">
                                    <option value="">职位部门</option>
                                    {volist name="groups" id="group"}
                                    <option value="{$key}">{$group}</option>
                                    {/volist}
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <input type="text" name="name" value="" placeholder="按姓名" autocomplete="off" class="layui-input" lay-filter="name">
                            </div>
                            <div class="layui-input-inline">
                                <input type="text" name="phone" placeholder="手机号码" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-input-inline" style="width: 170px;">
                                <button type="button" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-primary" title="清除条件" style="padding: 0 8px;" lay-submit lay-filter="reset"><i class="layui-icon" style="color:#009688;">&#xe640;</i></button>
                                <button type="button" class="layui-btn layui-btn-sm layui-btn-radius" lay-submit lay-filter="search">搜索</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/html" id="barDemo">
{if isset($sonAuth['edit'])}
    {{# if(d.id>1) { }}
    <input type="checkbox" name="status" value="{{ d.status }}" lay-skin="switch" lay-filter="switchStatus" lay-text="正常|冻结" {{ d.status == 1 ? 'checked' : '' }} data-href="{:url('/setting.SystemAdmin/edit')}?id={{ d.id }}">
    {{# } }}
    <a href="{:url('/setting.SystemAdmin/edit')}?id={{ d.id }}" class="layui-btn layui-btn-xs j-iframe-pop" lxb-data="{width: '560px', height: '470px'}" title="修改">修改</a>
{/if}
{if isset($sonAuth['del'])}
    {{# if(d.id>1) { }}
    <a href="{:url('/setting.SystemAdmin/del')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-danger j-tr-del">删除</a>
    {{# } }}
{/if}
</script>
<script type="text/html" id="toolbar">
    <div class="layui-btn-group fl">
{if isset($sonAuth['add'])}
        <a href="{:url('/setting.SystemAdmin/add')}" class="layui-btn layuiadmin-btn-admin j-iframe-pop" lxb-data="{width: '560px', height: '470px'}" title="添加员工">添加员工</a>
{/if}
    </div>
</script>
<script>
    layui.use(['form','table'], function() {
        var form = layui.form
            , table = layui.table;
        form.on('submit(search)', function(){
            tableIns.reload({
                where: form.val("formSearch"),
                page: {curr: 1}
            });
        });
        //头工具栏事件
        form.on('submit(reset)', function(){
            var searchs = form.val("formSearch");
            for (var i in searchs) {
                searchs[i] = '';
            }
            form.val("formSearch", searchs);
            tableIns.reload({
                where: null,
                page: {curr: 1}
            });
        });
        var tableIns = table.render({
            elem: '#dataTable'
            ,url: "{:url('/setting.SystemAdmin/index')}" //数据接口
            ,where: form.val("formSearch")
            ,page: true //开启分页
            ,skin: 'row'
            ,even: true
            ,limit: 20
            ,text: {
                none : '该职位暂无员工'
            }
            ,toolbar: '#toolbar'
            ,defaultToolbar: false
            ,cols: [[ //表头
                {field: 'real_name', width: 120, title: '姓名', fixed: 'left'}
                ,{field: 'group', width: 250, title: '部门职位'}
                ,{field: 'account', width: 200, title: '账号'}
                ,{field: 'phone', width: 120, title: '手机'}
                ,{field: 'last_time', width: 180, title: '最后登陆时间'}
                ,{field: 'ip', width: 150, title: '最后登陆IP'}
                ,{fixed: 'right', width: 220, title: '操作', templet: '#barDemo'}
            ]]
        });
    });
</script>
{/block}